﻿<metro:Window x:Class="Script.Components.Windows.LocationsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:metro="http://schemas.codeplex.com/elysium"
              xmlns:converters="clr-namespace:Apex.Common.GUI.Converters;assembly=Apex.Common.GUI"
        xmlns:params="http://schemas.codeplex.com/elysium/params"
              xmlns:vm="clr-namespace:Apex.Script.ViewModels;assembly=Apex.Script"
              xmlns:controls="clr-namespace:Script.Components.Controls"
        xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
              params:Manager.Theme="Dark"
              params:Manager.AccentBrush="{x:Static metro:AccentBrushes.Red}" 
              params:Manager.ContrastBrush="White" 
              DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="Location Editor" Height="540" Width="960">
    <Grid>
        <Grid.Resources>
            <converters:WidthToFontSizeConverter x:Key="TranslateTransformToRectViewboxVisualBrushConverter" />

        </Grid.Resources>
        <Grid Name="pnlContent" Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.75*"/>
                <ColumnDefinition Width="0.25*"/>
            </Grid.ColumnDefinitions>
            <Grid.BitmapEffect>
                <BlurBitmapEffect x:Name="blurEffect" Radius="0"/>
            </Grid.BitmapEffect>

            <m:Map x:Name="mpMap" CredentialsProvider="AoABVGalwGkm2NuyWsvnwtmtnATFSFn953PA0855xCbtX2KNsA2gx5-ZT5tLi_PE" Mode="AerialWithLabels" Grid.RowSpan="2" MouseUp="mpMap_MouseUp">

            </m:Map>
            
            <Rectangle Name="rectLiveIndicator" Fill="Red" VerticalAlignment="Bottom" Height="10" Visibility="Hidden" />

            <Grid x:Name="Glas" VerticalAlignment="Top" Height="75" Cursor="Hand">
                <Rectangle Fill="#19000000" RadiusX="3" RadiusY="3" Margin="-3" StrokeThickness="0"/>
                <Rectangle Fill="#19000000" RadiusX="2" RadiusY="2" Margin="-2" StrokeThickness="0"/>
                <Rectangle Fill="#33000000" RadiusX="1" RadiusY="1" Margin="-1" StrokeThickness="0"/>
                <Rectangle>
                    <Rectangle.Effect>
                        <BlurEffect Radius="7"/>
                    </Rectangle.Effect>
                    <Rectangle.Fill>
                        <VisualBrush ViewboxUnits="Absolute" 
                                     Viewbox="{Binding RenderTransform.Children[3], Converter={StaticResource TranslateTransformToRectViewboxVisualBrushConverter}, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type m:Map}}, UpdateSourceTrigger=PropertyChanged}" 
                                     AlignmentX="Left" AlignmentY="Top" Visual="{Binding ElementName=mpMap}" Stretch="None">
                            <VisualBrush.Transform>
                                <TranslateTransform X="0" />
                            </VisualBrush.Transform>
                        </VisualBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle>
                    <Rectangle.Fill>
                        <LinearGradientBrush EndPoint="0.825,0.735" StartPoint="0.238,0.15">
                            <GradientStop Color="#33FFFFFF" Offset="0.386"/>
                            <GradientStop Color="#4CFFFFFF" Offset="0.667"/>
                            <GradientStop Color="#21FFFFFF" Offset="0.812"/>
                            <GradientStop Color="#0EFFFFFF" Offset="0.249"/>
                        </LinearGradientBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <Rectangle Stroke="#35FFFFFF"/>
            </Grid>

            <StackPanel Orientation="Horizontal" Margin="5" Grid.Column="0" Grid.Row="1" Height="75" VerticalAlignment="Top">
                <StackPanel Width="150">
                    <TextBlock Text="Map Mode" Style="{StaticResource HeadingThreeStyle}"/>
                    <ComboBox Name="cmbMapModes" Margin="0,2,0,0" SelectedIndex="0">
                        <ComboBoxItem>Aerial, With Labels</ComboBoxItem>
                        <ComboBoxItem>Aerial, No Labels</ComboBoxItem>
                        <ComboBoxItem>Road</ComboBoxItem>
                    </ComboBox>
                </StackPanel>
                <StackPanel Margin="10,0,0,0">
                    <TextBlock Text="Add Current Location" Style="{StaticResource HeadingThreeStyle}"/>

                    <StackPanel Orientation="Horizontal" Margin="0,2,0,0" >
                        <TextBox Name="tbName" Text="Name" Height="32" Width="150"/>
                        <ComboBox Name="cmbWeather" VerticalAlignment="Center" Margin="10,0,0,0" Width="120"/>
                        <ComboBox Name="cmbTimeOfDay" VerticalAlignment="Center" Margin="10,0,0,0" Width="120"/>
                        <ComboBox Name="cmbTime" ItemStringFormat="hh\:mm" Height="32" Width="80" Margin="10,0,0,0"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <Grid  Margin="0,60,0,0" Grid.Column="0" Grid.Row="1" VerticalAlignment="Top">
                <TextBlock Text="*Name" Style="{StaticResource FootnoteItalicStyle}" Margin="280,0,0,0"/>
                <TextBlock Text="*Time Of Day" Style="{StaticResource FootnoteItalicStyle}" Margin="380,0,0,0"/>
                <TextBlock Text="*Weather Type" Style="{StaticResource FootnoteItalicStyle}" Margin="502,0,0,0"/>
                <TextBlock Text="*Time" Style="{StaticResource FootnoteItalicStyle}" Margin="631,0,0,0"/>
            </Grid>
            <Grid Grid.Column="1" Margin="10,0,0,0">
                <TextBlock Text="Saved Locations" Style="{StaticResource ThingHeadingStyle}"/>
                <Grid Margin="0,45,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="40" />
                        <ColumnDefinition Width="40" />
                        <ColumnDefinition Width="40" />
                    </Grid.ColumnDefinitions>
                    <metro:CommandButton Name="btnAdd" Header="Add" Width="30" Height="30" VerticalAlignment="Center" Grid.Column="0"
                                         Margin="5,0,0,0" Click="btnAdd_Click" >
                        <Rectangle Fill="{Binding Foreground, ElementName=btnAdd}" Width="15" Height="14">
                            <Rectangle.OpacityMask>
                                <VisualBrush Visual="{StaticResource appbar_add}"/>
                            </Rectangle.OpacityMask>
                        </Rectangle>
                    </metro:CommandButton>
                    <metro:CommandButton Name="btnEdit" Header="Edit" Width="30" Height="30" VerticalAlignment="Center" Grid.Column="1"
                                         Margin="5,0,0,0" Click="btnEdit_Click" >
                        <Rectangle Fill="{Binding Foreground, ElementName=btnEdit}" Width="15" Height="14">
                            <Rectangle.OpacityMask>
                                <VisualBrush Visual="{StaticResource appbar_edit}"/>
                            </Rectangle.OpacityMask>
                        </Rectangle>
                    </metro:CommandButton>
                    <metro:CommandButton Name="btnRemove" Header="Remove" Width="30" Height="30" VerticalAlignment="Center" Grid.Column="2"
                                         Margin="5,0,0,0" Click="btnRemove_Click" >
                        <Rectangle Fill="{Binding Foreground, ElementName=btnRemove}" Width="15" Height="14">
                            <Rectangle.OpacityMask>
                                <VisualBrush Visual="{StaticResource appbar_delete}"/>
                            </Rectangle.OpacityMask>
                        </Rectangle>
                    </metro:CommandButton>
                </Grid>

                <ListView Name="lvLocations" ItemsSource="{Binding Locations}" Background="{x:Null}" BorderBrush="{x:Null}" SelectionChanged="lvLocations_SelectionChanged" Margin="0,75,5,0">
                    <ListView.ItemTemplate>
                        <DataTemplate DataType="{x:Type vm:LocationViewModel}">
                            <StackPanel Orientation="Vertical" TextElement.Foreground="{StaticResource ForegroundBrush}">
                                <TextBlock Text="{Binding Name}" Style="{StaticResource HeadingThreeStyle}"/>
                                <TextBlock Text="{Binding ActualDate}" Style="{StaticResource HeadingThreeStyle}" Margin="0,3,0,0"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </Grid>

            <GridSplitter Grid.Column="1" ResizeBehavior="BasedOnAlignment" ResizeDirection="Columns" HorizontalAlignment="Left" Width="2" Height="Auto" Margin="0" Background="{DynamicResource LowlightBrush}" />
        </Grid>

        <Grid Name="progressRing" Visibility="Hidden" Grid.ColumnSpan="2">
            <Rectangle Fill="White" Opacity="0.25" />
            <metro:ProgressRing State="Indeterminate" VerticalAlignment="Center" HorizontalAlignment="Center" Width="50" Height="50"/>
        </Grid>

    </Grid>
</metro:Window>
